package Lab2;

import static java.lang.Math.sqrt;

public class MyPoint {
    private double x;
    private double y;

    public MyPoint() {
        x = 0;
        y = 0;
    }

    public MyPoint(double x, double y) {
        this.x = x;
        this.y = y;
    }

    public double distance(MyPoint p) {
        return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));
    }

    public static double distance(MyPoint p1, MyPoint p2) {
        return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
    }

    public static void main(String[] args) {
        MyPoint a = new MyPoint(-3, -4);
        MyPoint b = new MyPoint();

        System.out.println(a.distance(b));
        System.out.println(distance(a, b));
    }
}
